<?php


require_once(dirname(__FILE__).'/../lang/String.php');
class  filex{
	
static	Function getExtName($fileName)
	{
			$fileName=self::getFileName($fileName);  //o82  add can get empty extname.... no extname file can process..now .
			$GLOBALS["filenamePa"]=$fileName;
		$name = "";
		$extention = "";
		$fileName=new String($fileName);
		if ($fileName->length() > 0 && $fileName != null) { // --截取文件名
			$i = $fileName->lastIndexOf(".");
			$GLOBALS["lastIndexOf fileName"]=$fileName;
			$GLOBALS["lastIndexOf dot"]=$i;
			if ($i > -1 && $i < $fileName->length()) {
			 	$name = $fileName->substring(0, $i); // --文件名
				$extention = $fileName->substring($i + 1); // --扩展名
			}
		}
		return $extention;
	}
	
	//str_replace(find,replace,string,count)
	//"d:/z/aa.jpg" should ret  aa.jpg
	public static Function   getFileName($fileName) {
		 $fileName=str_replace("\\","/",$fileName);
		 $GLOBALS["fname:"]= $fileName;
		$name = "";
		$extention = "";
			$fileName=new String($fileName);
		//$lastSpashIndex=$fileName->lastIndexOf("\\");
//		if($lastSpashIndex==-1)
			$lastSpashIndex=$fileName->lastIndexOf("/");
			$GLOBALS["lastSpashIndex"]=$lastSpashIndex;
		if ($fileName->length() > 0 && $fileName != null) { // --截取文件名
		 
		 
				$name = $fileName->substring($lastSpashIndex+1); // --文件名
			 
		}
		return $name;

	}

}
/*
	$extname = filex::getExtName("d:/z/name.jpg");
	//$extname = filex::getFileName("d:/z/aa.jpg");
	print_r($GLOBALS);
	echo "..             ".$extname;*/